<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.11.0"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Lesson Project: Driver/w25qxx.c Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectalign">
   <div id="projectname">Lesson Project<span id="projectnumber">&#160;Beta V1.0</span>
   </div>
   <div id="projectbrief">Course Learning Template Engineering</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.11.0 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() { codefold.init(0); });
/* @license-end */
</script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function(){ initResizable(false); });
/* @license-end */
</script>
<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_7151b3cc910409bb744bd274374c738d.html">Driver</a></li>  </ul>
</div>
</div><!-- top -->
<div id="doc-content">
<div class="header">
  <div class="headertitle"><div class="title">w25qxx.c</div></div>
</div><!--header-->
<div class="contents">
<a href="w25qxx_8c.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno">    1</span> </div>
<div class="line"><a id="l00009" name="l00009"></a><span class="lineno">    9</span><span class="preprocessor">#include &quot;<a class="code" href="w25qxx_8h.html">w25qxx.h</a>&quot;</span></div>
<div class="line"><a id="l00010" name="l00010"></a><span class="lineno">   10</span> </div>
<div class="line"><a id="l00011" name="l00011"></a><span class="lineno">   11</span><span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code hl_function" href="w25qxx_8c.html#aa377cc00d44aae5ff8af53aa0f850078">w25qxx_set_cs</a>(uint8_t level);</div>
<div class="line"><a id="l00012" name="l00012"></a><span class="lineno">   12</span><span class="keyword">static</span> uint8_t <a class="code hl_function" href="w25qxx_8c.html#a73b671a3029c8b4e07ce05d58ec9c875">w25qxx_write_read_byte</a>(uint8_t tx_byte);</div>
<div class="line"><a id="l00013" name="l00013"></a><span class="lineno">   13</span> </div>
<div class="foldopen" id="foldopen00014" data-start="{" data-end="}">
<div class="line"><a id="l00014" name="l00014"></a><span class="lineno"><a class="line" href="w25qxx_8c.html#aa377cc00d44aae5ff8af53aa0f850078">   14</a></span><span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code hl_function" href="w25qxx_8c.html#aa377cc00d44aae5ff8af53aa0f850078">w25qxx_set_cs</a>(uint8_t level)</div>
<div class="line"><a id="l00015" name="l00015"></a><span class="lineno">   15</span>{</div>
<div class="line"><a id="l00016" name="l00016"></a><span class="lineno">   16</span>    HAL_GPIO_WritePin(GPIOA,GPIO_PIN_4,level ? GPIO_PIN_SET : GPIO_PIN_RESET);</div>
<div class="line"><a id="l00017" name="l00017"></a><span class="lineno">   17</span>}</div>
</div>
<div class="line"><a id="l00018" name="l00018"></a><span class="lineno">   18</span> </div>
<div class="foldopen" id="foldopen00019" data-start="{" data-end="}">
<div class="line"><a id="l00019" name="l00019"></a><span class="lineno"><a class="line" href="w25qxx_8c.html#a73b671a3029c8b4e07ce05d58ec9c875">   19</a></span><span class="keyword">static</span> uint8_t <a class="code hl_function" href="w25qxx_8c.html#a73b671a3029c8b4e07ce05d58ec9c875">w25qxx_write_read_byte</a>(uint8_t tx_byte)</div>
<div class="line"><a id="l00020" name="l00020"></a><span class="lineno">   20</span>{</div>
<div class="line"><a id="l00021" name="l00021"></a><span class="lineno">   21</span>    uint8_t rx_byte = 0;</div>
<div class="line"><a id="l00022" name="l00022"></a><span class="lineno">   22</span>    HAL_SPI_TransmitReceive(&amp;hspi1,&amp;tx_byte,&amp;rx_byte,1,100);</div>
<div class="line"><a id="l00023" name="l00023"></a><span class="lineno">   23</span>    <span class="keywordflow">return</span> rx_byte;</div>
<div class="line"><a id="l00024" name="l00024"></a><span class="lineno">   24</span>}</div>
</div>
<div class="line"><a id="l00025" name="l00025"></a><span class="lineno">   25</span> </div>
<div class="foldopen" id="foldopen00035" data-start="{" data-end="}">
<div class="line"><a id="l00035" name="l00035"></a><span class="lineno"><a class="line" href="w25qxx_8c.html#a621f3e3670e9f64bb3d320f96e55bcfd">   35</a></span>uint16_t <a class="code hl_function" href="w25qxx_8c.html#a621f3e3670e9f64bb3d320f96e55bcfd">w25qxx_read_id</a>(<span class="keywordtype">void</span>)</div>
<div class="line"><a id="l00036" name="l00036"></a><span class="lineno">   36</span>{</div>
<div class="line"><a id="l00037" name="l00037"></a><span class="lineno">   37</span>    uint16_t <span class="keywordtype">id</span> = 0;</div>
<div class="line"><a id="l00038" name="l00038"></a><span class="lineno">   38</span>    <a class="code hl_function" href="w25qxx_8c.html#aa377cc00d44aae5ff8af53aa0f850078">w25qxx_set_cs</a>(0);</div>
<div class="line"><a id="l00039" name="l00039"></a><span class="lineno">   39</span>    <a class="code hl_function" href="w25qxx_8c.html#a73b671a3029c8b4e07ce05d58ec9c875">w25qxx_write_read_byte</a>(0x90);</div>
<div class="line"><a id="l00040" name="l00040"></a><span class="lineno">   40</span>    <a class="code hl_function" href="w25qxx_8c.html#a73b671a3029c8b4e07ce05d58ec9c875">w25qxx_write_read_byte</a>(0x00);</div>
<div class="line"><a id="l00041" name="l00041"></a><span class="lineno">   41</span>    <a class="code hl_function" href="w25qxx_8c.html#a73b671a3029c8b4e07ce05d58ec9c875">w25qxx_write_read_byte</a>(0x00);</div>
<div class="line"><a id="l00042" name="l00042"></a><span class="lineno">   42</span>    <a class="code hl_function" href="w25qxx_8c.html#a73b671a3029c8b4e07ce05d58ec9c875">w25qxx_write_read_byte</a>(0x00);</div>
<div class="line"><a id="l00043" name="l00043"></a><span class="lineno">   43</span>    <span class="keywordtype">id</span> = <a class="code hl_function" href="w25qxx_8c.html#a73b671a3029c8b4e07ce05d58ec9c875">w25qxx_write_read_byte</a>(0xff);</div>
<div class="line"><a id="l00044" name="l00044"></a><span class="lineno">   44</span>    <span class="keywordtype">id</span> &lt;&lt;= 8;</div>
<div class="line"><a id="l00045" name="l00045"></a><span class="lineno">   45</span>    <span class="keywordtype">id</span> |= <a class="code hl_function" href="w25qxx_8c.html#a73b671a3029c8b4e07ce05d58ec9c875">w25qxx_write_read_byte</a>(0xff);</div>
<div class="line"><a id="l00046" name="l00046"></a><span class="lineno">   46</span>    <a class="code hl_function" href="w25qxx_8c.html#aa377cc00d44aae5ff8af53aa0f850078">w25qxx_set_cs</a>(1);</div>
<div class="line"><a id="l00047" name="l00047"></a><span class="lineno">   47</span>    <span class="keywordflow">return</span> id;</div>
<div class="line"><a id="l00048" name="l00048"></a><span class="lineno">   48</span>}</div>
</div>
<div class="ttc" id="aw25qxx_8c_html_a621f3e3670e9f64bb3d320f96e55bcfd"><div class="ttname"><a href="w25qxx_8c.html#a621f3e3670e9f64bb3d320f96e55bcfd">w25qxx_read_id</a></div><div class="ttdeci">uint16_t w25qxx_read_id(void)</div><div class="ttdoc">Get w25qxx's id.</div><div class="ttdef"><b>Definition</b> <a href="#l00035">w25qxx.c:35</a></div></div>
<div class="ttc" id="aw25qxx_8c_html_a73b671a3029c8b4e07ce05d58ec9c875"><div class="ttname"><a href="w25qxx_8c.html#a73b671a3029c8b4e07ce05d58ec9c875">w25qxx_write_read_byte</a></div><div class="ttdeci">static uint8_t w25qxx_write_read_byte(uint8_t tx_byte)</div><div class="ttdef"><b>Definition</b> <a href="#l00019">w25qxx.c:19</a></div></div>
<div class="ttc" id="aw25qxx_8c_html_aa377cc00d44aae5ff8af53aa0f850078"><div class="ttname"><a href="w25qxx_8c.html#aa377cc00d44aae5ff8af53aa0f850078">w25qxx_set_cs</a></div><div class="ttdeci">static void w25qxx_set_cs(uint8_t level)</div><div class="ttdef"><b>Definition</b> <a href="#l00014">w25qxx.c:14</a></div></div>
<div class="ttc" id="aw25qxx_8h_html"><div class="ttname"><a href="w25qxx_8h.html">w25qxx.h</a></div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.11.0
</small></address>
</div><!-- doc-content -->
</body>
</html>
